<template>
  <div>
    <c-table
      border
      class="table-sm"
      v-loading="loading"
      :stripe="false"
      :columns="tableColumns"
      :data="tableData"
    ></c-table>

    <div class="query-pagination">
      <div></div>
      <el-pagination
        layout="total, prev, pager, next, jumper"
        :current-page.sync="queryParams.index"
        :page-size="queryParams.size"
        :total="tableCount"
        @current-change="getData"
      ></el-pagination>
    </div>
  </div>
</template>

<script>
export default {
  components: {},
  props: {
    params: {
      type: Object,
      default() {
        return {}
      },
    },
  },
  data() {
    return {
      tableName: 'datum_customer_industrial_service_import_view',
      queryParams: {
        index: 1,
        size: 20,
      },
      loading: false,

      tableData: [],
      tableCount: 0,
      tableColumns: [
        { attrs: { label: '所属地区', prop: 'address' } },
        { attrs: { label: '经营者', prop: 'business_name' } },
        { attrs: { label: '身份证号码', prop: 'lender_idcard' } },
        { attrs: { label: '经营种类', prop: 'product_name' } },
        { attrs: { label: '现有存量', prop: 'store_num' } },
        { attrs: { label: '经营服务能力', prop: 'produce_capacity' } },
        { attrs: { label: '营业收入（万元）', prop: 'current_year_output' } },
        { attrs: { label: '附件', prop: 'attachment' } },
      ],
    }
  },
  computed: {},
  watch: {
    params: {
      handler: function () {
        this.queryParams = Object.assign(this.queryParams, this.params)
      },
      deep: true,
      immediate: true,
    },
  },
  created() {},
  mounted() {},
  methods: {
    async getData() {
      this.loading = true
      const [res] = await this.$utils.promise(
        this.$api.getData(this.$serviceName, this.tableName, this.queryParams)
      )
      this.loading = false
      const data = (res && res.data) || {}
      this.tableData = data.data || []
      this.tableCount = data.totalCount || 0
    },
  },
}
</script>

<style lang="scss" scoped></style>
